<!DOCTYPE html>

<html>
<head>
  <style>
    .container {
      height: 240px;
      width: 120px;
      overflow: hidden;
      position: relative;
      z-index: 0; /* create stacking context */
      border: 1px solid black;
    }
    
    .box {
      position: relative;
      width: 100px;
      height: 100px;
      margin: 10px;
      background-color: blue;
    }
    
    .animating {
      animation: spin 2s infinite linear;
    }
    
    @keyframes spin {
      from { transform: rotate(90deg); }
      to   { transform: rotate(360deg); }
    }
  </style>
  <script>
    if (window.testRunner) {
      testRunner.dumpAsText();
      testRunner.waitUntilDone();
    }
      
    function runTest()
    {
      var box = document.getElementById('to-animate');
      box.addEventListener('animationstart', animationStarted, false);
      box.className = 'animating box';
    }
    
    function animationStarted()
    {
      if (window.testRunner) {
        var layerText = internals.layerTreeAsText(document);
        // The animation can progress before the start event is handled, so remove the
        // effects as they can vary.
        layerText = layerText.replace(/\[.*,.*,.*,.*\]/g, '[...]');
        document.getElementById('layers').innerText = layerText;
        testRunner.notifyDone();
      }
    }
    window.addEventListener('load', runTest, false);
  </script>
</head>
<body>
  <div class="container">
    <div id="to-animate" class="box"></div>
    <!-- This div will get a layer -->
    <div class="box"></div>
  </div>
  <!-- This div should not get a layer -->
  <div class="box"></div>
<pre id="layers">Layer tree goes here in DRT</pre>
</body>
</html>
